#region

using System;
using System.Collections.ObjectModel;
using System.Linq.Expressions;

#endregion

/// <summary>
/// AA set of permissions to use
/// When the internal lookup dictionary is used, it contains references to
/// all the items in the collection if TItem is a reference type, or copies of all 
/// the items in the collection if TItem is a value type. Thus, using the lookup 
/// dictionary may not be appropriate if TItem is a value type. 
/// </summary>
[Serializable]
public class MarketRules : KeyedCollection<String, Expression<Func<bool>>>
{
    /// <summary>
    /// Opens the store permission.
    /// </summary>
    /// <param name="jobLevel">The job level.</param>
    /// <returns></returns>
    public static Expression<Func<bool>> OpenStorePermission(JobLevel jobLevel)
    {
        return
            () =>
            jobLevel.Equals(JobLevel.Manager) ||
            jobLevel.Equals(JobLevel.AssistantManager);
    }

    #region Overrides of KeyedCollection<string,Expression<Func<bool>>>

    /// <summary>
    /// When implemented in a derived class, extracts the key from the specified element.
    /// </summary>
    /// <returns>
    /// The key for the specified element.
    /// </returns>
    /// <param name="item">The element from which to extract the key.</param>
    protected override string GetKeyForItem(Expression<Func<bool>> item)
    {
        return item.ToString();
    }

    #endregion
}